<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.fc.util.*" %>
<%@ page import="com.fc.model.Admin" %>
<%@ page import="com.fc.control.AdminControl" %>
<%@ include file="../login/login_check.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>admin</title>
<script>
  	$(function(){
				//添加隔行换色
				$("tbody tr:odd").addClass("oddTR");
				
				// 添加鼠标经过样式
				$("tbody tr").mouseover(function(){
					$(this).addClass("mouseOverTR");
					$(this).children("td").each(function(){
						$(this).addClass("mouseOverTD");
						});
				});
					
				
				$("tbody tr").mouseout(function(){
					$(this).removeClass(["mouseOverTR"]);
					$(this).children("td").each(function(){
							$(this).removeClass(["mouseOverTD"]);
						});
					});
			})
			
  </script>
</head>
<body>
<form>
<strong>管理员列表</strong>
   <table>
   <thead>
   <tr>
   	<th width="100">编号</th>
   	<th width="100">用户名</th>
   	<th width="100">密码</th>
   	<th width="100">角色</th>
   	<th width="100">性别</th>
   	<th width="150">电话</th>
   	<th width="150">操作</th>
   	<th width="150">操作</th>  
   </tr>
</thead>
<tbody>
<%
	request.setCharacterEncoding("UTF-8");
	String username=ParamUtil.getString(request,"username",null);
	//String password=ParamUtil.getString(request,"password",null);
	//int role=ParamUtil.getInt(request,"role");
	//String phone=ParamUtil.getString(request,"phone",null);
	
	int pages = ParamUtil.getInt(request, "pages", 0);
	int id=ParamUtil.getInt(request,"id",0);
	int rowsPerPage = ParamUtil.getInt(request, "pageSize", 10);
	AdminControl ac = new AdminControl();
	Admin admin = new Admin();
	//admin = ac.getAdminInfo(id);
	List<Admin> list = new ArrayList<Admin>();
	if(username!=null)
	{
	   list = (List) ac.getAdmin(pages,rowsPerPage,username);
	}
	else
	{
	   list = (List) ac.getAdmin(pages,rowsPerPage);
	}
	      
	for (int i = 0; i < list.size(); i++) {
		admin = list.get(i);
%>  
	
		<tr>
	    <td align="center"><%=admin.getId()%></td>
		<td align="center"><%=admin.getUsername()%></td>
		<td align="center"><%=admin.getPassword()%></td>
		<td align="center">
		<% 
		if(admin.getRole()==1){out.println("分店长");}
		if(admin.getRole()==2){out.println("总店长");}
		if(admin.getRole()==3){out.println("管理员");}	
		%></td>
		<td align="center">
		<%
		if(admin.getSex()==1){out.println("男");}
		if(admin.getSex()==2){out.println("女");}
		 %></td>
		<td align="center"><%=admin.getPhone()%></td>
		<td align="center">
		<a href="admin_update.jsp?id=<%=admin.getId()%>">信息修改</a>
		</td>
		<td align="center">
		<a href="admin_delete_do.jsp?id=<%=admin.getId()%>" onclick='return confirm("确定要删除吗？")'>删除</a>
		</td>
		</tr>
	<%
		}
	%>   	
   	</tbody>
   </table>
  <%
			out.println(AdminControl.pageInstance.getToolsMenu(pages));
	  %>
   
    <p>	    
          <input type="button" value="添加管理员" onclick="window.location.href='admin_add.jsp'" />
	</p>
	</form>
</body>
</html>